/*
题目地址:https://leetcode-cn.com/problems/water-bottles/
题目标签:数学
*/

#include <iostream>

class Solution {
   public:
    int numWaterBottles(int numBottles, int numExchange) {
        int ans = numBottles, empty = numBottles;
        while (empty >= numExchange) {
            div_t d = div(empty, numExchange);
            empty = d.quot + d.rem;
            ans += d.quot;
        }
        return ans;
    }
};

int main() {
    Solution Solution;
    std::cout << Solution.numWaterBottles(9, 3) << std::endl;  // 13
    std::cout << Solution.numWaterBottles(9, 3) << std::endl;  // 13
    std::cout << Solution.numWaterBottles(9, 3) << std::endl;  // 13
    std::cout << Solution.numWaterBottles(9, 3) << std::endl;  // 13
}